package com.api.shopapi.service.impl;

import com.api.shopapi.entity.GoodsClassBusiness;
import com.api.shopapi.entity.dto.GoodsClassBusinessDTO;
import com.api.shopapi.mapper.GoodsClassBusinessMapper;
import com.api.shopapi.mapper.GoodsClassMapper;
import com.api.shopapi.service.GoodsClassBusinessService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service("GoodsClassBusinessServiceImplOne")
public class GoodsClassBusinessServiceImpl implements GoodsClassBusinessService {


    @Autowired
    private GoodsClassBusinessMapper goodsClassBusinessMapper;

    @Override
    @Transactional
    public int insert(GoodsClassBusiness goodsClassBusiness) {
        return goodsClassBusinessMapper.insert(goodsClassBusiness);
    }

    @Override
    public int update(GoodsClassBusiness goodsClassBusiness) {
        return goodsClassBusinessMapper.update(goodsClassBusiness);
    }

    @Override
    public GoodsClassBusiness getByGoodsClassBusinessCode(String goodsClassBusinessCode) {
        return goodsClassBusinessMapper.getByGoodsClassBusinessCode(goodsClassBusinessCode);
    }

    @Override
    public GoodsClassBusiness getByName(String name,String businessCode) {
        return goodsClassBusinessMapper.getByName(name,businessCode);
    }

    @Override
    public List<GoodsClassBusiness> getListByBusinessCode(String businessCode) {
        return goodsClassBusinessMapper.getListByBusinessCode(businessCode);
    }

    @Override
    public List<GoodsClassBusinessDTO> getListByBusinessCodeAndParent(String businessCode,String parentGoodsClassBusinessCode) {
        return goodsClassBusinessMapper.getListByBusinessCodeAndParent(businessCode,parentGoodsClassBusinessCode);
    }

    @Override
    public List<GoodsClassBusinessDTO> getListByParentAll(String businessCode, String parentGoodsClassBusinessCode) {
        return goodsClassBusinessMapper.getListByParentAll(businessCode,parentGoodsClassBusinessCode);
    }

    @Override
    public PageInfo<GoodsClassBusiness> getPageList(int pageIndex, int pageSize, String businessCode, String name, int status) {
        PageHelper.startPage(pageIndex,pageSize);
        List<GoodsClassBusiness> goodsClassBusinessList = goodsClassBusinessMapper.getPageList(businessCode, name, status);
        PageInfo<GoodsClassBusiness> goodsClassBusinessPageInfo=new PageInfo<>(goodsClassBusinessList);
        return goodsClassBusinessPageInfo;
    }

}
